const { defineConfig } = require('@vue/cli-service')
const path = require('path')

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: process.env.NODE_ENV !== 'production',
  devServer: {
    port: 8081, // 前端端口，避免与后端冲突
    open: true,
    // 代理配置，连接你的Spring Boot后端
    proxy: {
      '/api': {
        target: 'http://localhost:9090', // 后端端口
        changeOrigin: true,
        secure: false,
        logLevel: 'debug' // 开启代理日志，便于调试
      }
    }
  },
  // 配置 webpack
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      },
      fallback: {
        "path": require.resolve("path-browserify"),
        "buffer": require.resolve("buffer"),
        "process": require.resolve("process/browser")
      }
    }
  },
  // 处理路径问题
  chainWebpack: config => {
    config.resolve.alias.set('@', path.resolve(__dirname, 'src'))
  }
})
